package com.ele.service;

import java.sql.SQLException;
import java.util.List;

import com.ele.dao.AdminDao;
import com.ele.pojo.Admin;
import com.ele.pojo.Shop;


public class AdminService {

	public Admin adminLogin(String admin, String password) {
		AdminDao adminDao = new AdminDao();
		
		try {
			Admin adm = adminDao.adminLogin(admin ,password);
			return adm;
		} catch (SQLException e) {
			return null;
		}
		
	}

	public Boolean addShop(Shop shop) {
		AdminDao dao = new AdminDao();
		try {
			dao.addShop(shop);
		} catch (SQLException e) {
			return false;
		}
		return true;
	}

	/**
	 * 	查询所有商铺
	 * @return	返回包含所有商铺信息的list集合
	 */
	public List<Shop> selectShop() {
		AdminDao dao = new AdminDao();
		try {
			return dao.selectShop();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	/**
	 * 	以商铺编号查询商铺信息
	 * @param id	商铺编号
	 * @return
	 */
	public Shop selectShop(Integer id) {
		AdminDao dao = new AdminDao();
		try {
			return dao.selectShop(id);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

	public Boolean updateShop(Shop shop) {
		AdminDao dao = new AdminDao();
		try {
			return dao.updateShop(shop);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return false;
	}

}
